﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IList<dbPoll_Application.Models.Poll>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" src="../../Scripts/Poll-Index.js"></script>
    <div class="pageHeadingContainer"><h2 class="pageHeading">Polls</h2></div>
    <div id="contentContainer">
    <div id="filterUsers"><label for="filter">Filter</label><input type="text" name="filter" id="filter" value="Enter a keyword to filter the list..." /></div>
    <table class="questions">
    <tr>
    <th class="pollIDCol">PollID</th>
    <th class="pollNameCol">Name</th>
    <th class="pollQuestionsCol">Questions</th>
    <th class="pollParticipantsCol">Participants</th>
    <th class="pollStartCol">Start Time</th>
    </tr>
    <% foreach (var poll in Model)
       {%>
    <tr class="pollIndexRow">
    <td class="pollIDCol"><%= poll.pollID %></td>
    <td class="pollNameCol"><%= Html.ActionLink(poll.name, "Questions", "Poll", new { pollID = poll.pollID, pollName = poll.name }, null) %></td>
    <td class="pollQuestionsCol"><%= poll.questions.Count %></td>
    <td class="pollParticipantsCol"><%= poll.participants.Count %></td>
    <% if (poll.pollStart.HasValue)
       { %>
    <td class="pollStartCol"><%= poll.pollStart.Value.ToString("dd/MM/yyyy hh:mm tt")%></td>
    <% }
       else
       { %>
    <td class="pollStartCol">-</td>
    <% } %>
    </tr>
    <% } %>
    </table>
    <% if (User.IsInRole("Poll Administrator"))
       { %>
        <% using (Html.BeginForm("CreatePoll", "Poll", FormMethod.Post, new { @id = "SAQForm" }))
           { %>
        <input type="submit" value="Create Poll" />
        <% } %>
    <% } %>
    </div>
</asp:Content>
